import wepy from 'wepy'

export default class extends wepy.mixin {
  data = {
    cates: [],
    activeKey: 0,
    // 二级分类数据
    secondCate: []
  }

  config = {
  }

  methods = {
    sidebaChange (e) {
      const index = e.detail
      this.secondCate = this.cates[index].children
    }
  }
  async gitCateList () {
    const {data:res} = await wepy.get('/categories')
    if (res.meta.status !== 200) return wepy.baseToast()
    this.cates = res.message
    this.secondCate = res.message[0].children
    this.$apply()
  }
  onLoad () {
    this.gitCateList()
  }
  onShow () {
    this.$parent.setTabbatBadge()
  }
}
